<template>
  <div style="">
    <div style="height:calc(100vh - 50px);width: 100vw;">
      <keep-alive>
        <router-view v-if="$route.meta.keepAlive"></router-view>
      </keep-alive>
      <router-view v-if="!$route.meta.keepAlive"></router-view>
    </div>

    <!-- <div class="vol-tabbar">
      测试版本 v1.0.0 -->
      <!-- <van-tabbar v-model="navigate.active" @change="change">
        <van-tabbar-item
          v-for="(item, index) in menu"
          :key="index"
          :icon="item.icon"
          >{{ item.text }}</van-tabbar-item
        >
      </van-tabbar> -->
    <!-- </div> -->
  </div>
</template>
<script>
import { Tabbar, TabbarItem } from "vant";

export default {
  components: {
    "van-tabbar": Tabbar,
    "van-tabbar-item": TabbarItem
  },
  data() {
    return {
      navigate: {
        active: 0,
        path: []
      },
      menu: [
        { text: "沟  通", icon: "chat-o", path: "/Communication" },
        // { text: "报  价", icon: "coupon-o", path: "/price" },
        // { text: "菜  单", icon: "apps-o", path: "/option" },
        { text: "服  务", icon: "smile-comment-o", path: "/service" },
        { text: "客  户", icon: "home-o", path: "/formal" },

        // { text: "社  圈", icon: "tv-o", path: "/community" },
        { text: "交  易", icon: "refund-o", path: "/transaction" },
        { text: "我  的", icon: "user-circle-o", path: "/user" }
      ]
    };
  },
  methods: {
    change(index) {
      this.$router.push({ path: this.menu[index].path });
    }
  },
  watch: {
    $route: {
      deep: true,
      handler(a, b) {
        this.navigate.active = this.menu.findIndex(item => {
          return item.path == a.path;
        });
      }
    }
  },
  created() {
    this.navigate.path = this.menu.map(x => {
      return x.path;
    });
    let index = this.navigate.path.indexOf(this.$route.path);
    if (index != -1) {
      this.navigate.active = index;
    }
    this.$store.getters.data().navigate = this.navigate;
  }
};
</script>
<style lang="less" scoped>
.vol-tabbar {
  font-size: 0.5rem;
  text-align: center;
  color:#777575
}
</style>
